package com.liyunc.demo.bundle.file.manager.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * @author liyuncong
 * @version 1.0
 * @file AssetFileConfiguration.java
 * @brief AssetFileConfiguration
 * @details AssetFileConfiguration
 * @date 2022-03-21
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2022-03-21                 liyuncong      Created
 */
@Configuration
@EnableConfigurationProperties(value = AssetFileConfigProperties.class)
public class AssetFileConfiguration {

    private static final int MAX_BUFFER_SIZE = 2048;

    /**
     * 配置CommonsMultipartResolver.
     */
    @Bean
    public CommonsMultipartResolver multipartResolver() {
        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
        resolver.setDefaultEncoding("UTF-8");
        // 指定文件载入内存大小
        resolver.setMaxInMemorySize(MAX_BUFFER_SIZE);
        return resolver;
    }
}
